use alloc::{string::String, vec::Vec};
pub fn cd(args: Vec<String>) {
    if args.len() != 2 {
        println!("Usage: cd <folder>\n");
        return;
    }

    let path = args[1].clone();

    let k = syscall::op::open(path.clone(), syscall::op::OpenMode::Read);
    if k == usize::MAX {
        println!("cd: {}: No such directory", path);
        return;
    }

    if syscall::op::ftype(k) == syscall::scheme::SchemeTy::File {
        println!("cd: {}: No such directory", path);
        return;
    }

    syscall::op::close(k);

    syscall::op::change_cwd(path.clone());
}
